home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / quickcom.arc / TERMINAL.BAS < prev    next >
BASIC Source File  |  1989-06-09  |  2KB  |  76 lines

  1. DEFINT A-Z
  2.  
  3. DECLARE SUB Filter (InString$)
  4.  
  5. COLOR 7, 1                      ' Set screen color.
  6. CLS
  7.  
  8. Quit$ = CHR$(0) + CHR$(16)      ' Value returned by INKEY$
  9.                                 ' when ALT+q is pressed.
  10.  
  11. ' Set up prompt on bottom line of screen and turn cursor on:
  12. LOCATE 24, 1, 1
  13. PRINT STRING$(80, "_");
  14. LOCATE 25, 1
  15. PRINT TAB(30); "Press ALT+q to quit";
  16.  
  17. VIEW PRINT 1 TO 23              ' Print between lines 1 & 23.
  18.  
  19. ' Open communications (1200 baud, no parity, 8-bit data,
  20. ' 1 stop bit, 256-byte input buffer):
  21. OPEN "COM1:9600,N,8,1" FOR RANDOM AS #1 LEN = 256
  22.  
  23. DO                              ' Main communications loop.
  24.  
  25.    KeyInput$ = INKEY$           ' Check the keyboard.
  26.  
  27.    IF KeyInput$ = Quit$ THEN    ' Exit the loop if the user
  28.       EXIT DO                   ' pressed ALT+q.
  29.  
  30.    ELSEIF KeyInput$ <> "" THEN  ' Otherwise, if the user has
  31.       PRINT #1, KeyInput$;      ' pressed a key, send the
  32.    END IF                       ' character typed to the modem.
  33.  
  34.    ' Check the modem. If characters are waiting (EOF(1) is
  35.    ' true), get them and print them to the screen:
  36.    IF NOT EOF(1) THEN
  37.  
  38.       ' LOC(1) gives the number of characters waiting:
  39.       ModemInput$ = INPUT$(LOC(1), #1)
  40.  
  41.       Filter ModemInput$        ' Filter out line feeds and
  42.       PRINT ModemInput$;        ' backspaces, then print.
  43.    END IF
  44. LOOP
  45.  
  46. CLOSE                           ' End communications.
  47. CLS
  48. END
  49.  
  50. '
  51. ' ========================= FILTER ==========================
  52. '     Filters characters in an input string.
  53. ' ============================================================
  54. '
  55. SUB Filter (InString$) STATIC
  56.  
  57.    ' Look for backspace characters and recode them to
  58.    ' CHR$(29) (the LEFT cursor key):
  59.    DO
  60.       BackSpace = INSTR(InString$, CHR$(8))
  61.       IF BackSpace THEN
  62.          MID$(InString$, BackSpace) = CHR$(29)
  63.       END IF
  64.    LOOP WHILE BackSpace
  65.  
  66.    ' Look for line-feed characters and remove any found:
  67.    DO
  68.       LineFeed = INSTR(InString$, CHR$(10))
  69.       IF LineFeed THEN
  70.          InString$ = LEFT$(InString$, LineFeed - 1) + MID$(InString$, LineFeed + 1)
  71.       END IF
  72.    LOOP WHILE LineFeed
  73.  
  74. END SUB
  75.  
  76.